package 算法_回溯;

import java.util.ArrayList;

public class Subsets {
    public static void main(String[] args) {
        String[] a = {"a", "b"};
        ArrayList<String> s = new ArrayList<>();
        ArrayList<ArrayList<String>> t = new ArrayList<>();
        get_subsets(0, a, s, t);
        System.out.println(t.toString());
    }

    private static void get_subsets(int idx, String[] a, ArrayList<String> s, ArrayList<ArrayList<String>> t) {
        t.add(new ArrayList<>(s));
        for (int i = idx; i < a.length; i++) {
            s.add(a[i]);
            get_subsets(idx + 1, a, s, t);
            s.remove(s.size() - 1);
        }
    }
}
